package com.geor.gcv.ict.train;

import org.opencv.core.CvType;
import org.opencv.core.Mat;

public class TrainerKNNGraphic extends TrainerAbstract {
	MlKNN knn = new MlKNN();

	@Override
	public void train(Mat trainData, Mat label, String out) {
		knn.train(trainData, label, out);
	}

	public MlKNN getKnn() {
		return knn;
	}

	public static Mat genSimpleMat(Mat mat) {
		Mat sample = new Mat(1, mat.rows() * mat.cols(), CvType.CV_32FC1);
		int j = 0;
		for (int n = 0; n < mat.rows(); n++) {
			for (int m = 0; m < mat.cols(); m++) {
				sample.put(0, j++, mat.get(n, m)[0]);
			}
		}
		return sample;
	}

}
